<?php

namespace  App\Http\Controllers\V1;

use App\Helpers\Logger\SLogger;
use App\Helpers\RestResponseFactory;
use App\Helpers\RestUtils;
use App\Http\Controllers\Controller;
use App\Models\Factory\ProductFactory;
use App\Models\Factory\SmsFactory;
use App\Models\Factory\UserFactory;
use App\Models\Orm\Banner;
use App\Services\Core\Sms\Dahan\DahanService;
use Illuminate\Http\Request;
/**
 * Class GeetesController
 * @package App\Http\Controllers\V1
 * 短信
 */
class ProductController extends  Controller
{

    /**
     *获取产品列表
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function getProduct(Request $request)
    {
        $info = $request ->all();
        $data = ProductFactory::getList($info['type']);

        return RestResponseFactory::ok($data,200);

    }

    public function apply(Request $request)
    {
        $info = $request ->all();
        $user = $request -> get('user');


        $data = ProductFactory::addProductApply($user,$info);

        if($data == false){
            SLogger::getStream()->info($user->id.'点击统计插入失败');
        }

        return RestResponseFactory::ok(RestUtils::getStdObj(),200);

    }


    public function detail(Request $request)
    {
        $info = $request ->all();
        $user = $request -> get('user');


        $data = ProductFactory::addProductDetail($user,$info);

        if($data == false){
            SLogger::getStream()->info($user->id.'详情统计插入失败');
        }

        return RestResponseFactory::ok(RestUtils::getStdObj(),200);

    }



}